import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const modulesFiles = require.context('@store/modules', true, /\.js$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  // 兼容处理：.default 获取 ES6 规范暴露的内容; 后者获取 commonJS 规范暴露的内容
  modules[moduleName] = value.default || value

  return modules
}, {})

export default new Vuex.Store({
  state: {
    userInfo: {},
    menuList:[
      {path: 'home', meta:{title:'首页'}},
      {path: 'enviroment', meta:{title:'环境'}},
      {path: 'software', meta:{title:'软件包'}},
      {path: 'license', meta:{title:'License'}},
    ]
  },
  modules: {
    ...modules
  },
  mutations: {
    getUserInfo(state, name) {

    }
  },
  actions: {
    asyncGetUserInfo({ commit }) {

    }
  },
})
